from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
from django.contrib.auth.models import Group
from django.contrib.sites.models import Site
from django.views.generic.simple import direct_to_template, redirect_to
from pyplog.sitemaps import *

admin.autodiscover()

sitemaps = {
	"blog" : BlogMap,
	"blog-index" : BlogIndexMap,
	"pages" : PageMap,
	"photos" : PhotoMap,
}

urlpatterns = patterns("",
	(r"^$", redirect_to, { "url" : "/blog/" }),
	(r"^admin/(.*)", admin.site.root),
	(r"^artists/", include("pyplog.artists.urls")),
	(r"^blog/", include("pyplog.blog.urls")),
	(r"^photos/", include("pyplog.photos.urls")),
	(r"^page/", include("pyplog.pages.urls")),
	(r"^robots.txt$", direct_to_template,
	{
		"template" : "robots.txt",
		"mimetype" : "text/plain",
		"extra_context" : {
			"site_domain" : Site.objects.get(pk = settings.SITE_ID).domain,
		},
	}),
	url(r"^sitemap.xml$", "django.contrib.sitemaps.views.sitemap", { "sitemaps" : sitemaps }, name = "sitemap"),
)

admin.site.unregister(Group)
